package com.bcx.crm.spring_boot.ApplicationEvent;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Created by ys on 2018/4/8.
 * 发布事件类
 */
@Component
public class DemoPublisher {
    @Autowired
    private ApplicationContext applicationContext;  //注入applicationContext来发布事件

    //使用application的publishEvent来发布事件
    public void publisher(String msg){
        applicationContext.publishEvent(new DemoEvent(this,msg));
    }
}
